package org.example.acm;

import java.util.*;

public class StackRemainSolution {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] nums = scanner.nextLine().split(" ");
        StackRemainSolution solution = new StackRemainSolution();
        Deque<Integer> res = solution.getRemain(nums);
        int i = 0;
        int size = res.size();
        while (!res.isEmpty()) {
            System.out.print(res.pop());
            if (i < size - 1) {
                System.out.print(" ");
            }
            i++;
        }
    }

    private Deque<Integer> getRemain(String[] nums) {
        LinkedList<Integer> stack = new LinkedList<>();
        for (int i=0;i<nums.length;i++) {
            int add = Integer.parseInt(nums[i]);
            int sum = add;
            for (int j=0;j<stack.size();j++) {
                sum -= stack.get(j);
                if (sum == 0) {
                    //清空j至栈顶
                    stack.subList(0, j+1).clear();
                    add *= 2;
                    sum = add;
                } else if (sum < 0) {
                    break;
                }
            }
            stack.push(add);
        }
        return stack;
    }

}
